import { Drawer } from "antd";
import React, { useState } from 'react';
import { CommonModal } from "../modal";
/**
 * 弹窗hook
*/
export function useModal({ slot, modal }) {
    const [showProps, setShowProps] = useState(null);
    const [state, setState] = useState();
    return {
        state,
        row: showProps,
        node: (<CommonModal open={!!showProps} onCancel={(e) => {
                modal?.onCancel?.(e);
                setShowProps(null);
            }} {...modal}>
        {showProps &&
                slot({
                    row: showProps,
                    onChange: v => {
                        setState(v);
                    },
                })}
      </CommonModal>),
        show: (props) => setShowProps(props),
        hide: () => setShowProps(null),
    };
}
